#ifndef __OPTO_SWITCH_H
#define __OPTO_SWITCH_H
#include "device.h"

//#define LEFT_FORWARD_PORT        GPIOB
//#define RIGHT_FORWARD_PORT       GPIOB
//#define LEFT_BACK_PORT           GPIOC
//#define RIGHT_BACK_PORT          GPIOC
//#define SIDE_PORT                GPIOC
//#define LEFT_BULLET_PORT         GPIOB
//#define RIGHT_BULLET_PORT        GPIOB
//#define SPARE_PORT               GPIOC
//#define LED_1_PORT	  	 		 GPIOC
//#define LED_2_PORT	  	 		 GPIOB

//#define LED_RED       	  		 GPIO_PIN_0
//#define LED_BLUE		 		 GPIO_PIN_7
//#define LEFT_FORWARD_PIN         GPIO_PIN_7
//#define RIGHT_FORWARD_PIN        GPIO_PIN_6
//#define LEFT_BACK_PIN            GPIO_PIN_0
//#define RIGHT_BACK_PIN           GPIO_PIN_3
//#define SIDE_PIN                 GPIO_PIN_2
//#define LEFT_BULLET_PIN          GPIO_PIN_8
//#define RIGHT_BULLET_PIN         GPIO_PIN_5
//#define SPARE_PIN                GPIO_PIN_1

//#define LEFT_FORWARD_PORT_CLK_ENABLE       __HAL_RCC_GPIOB_CLK_ENABLE
//#define RIGHT_FORWARD_PORT_CLK_ENABLE      __HAL_RCC_GPIOB_CLK_ENABLE
//#define LEFT_BACK_PORT_CLK_ENABLE          __HAL_RCC_GPIOC_CLK_ENABLE
//#define RIGHT_BACK_PORT_CLK_ENABLE         __HAL_RCC_GPIOC_CLK_ENABLE
//#define SIDE_PORT_CLK_ENABLE               __HAL_RCC_GPIOC_CLK_ENABLE
//#define LEFT_BULLET_PORT_CLK_ENABLE        __HAL_RCC_GPIOB_CLK_ENABLE
//#define RIGHT_BULLET_PORT_CLK_ENABLE       __HAL_RCC_GPIOB_CLK_ENABLE
//#define SPARE_PORT_CLK_ENABLE              __HAL_RCC_GPIOC_CLK_ENABLE
//#define LED_RED_PORT_CLK_ENABLE			   __HAL_RCC_GPIOC_CLK_ENABLE
//#define LED_BLUE_PORT_CLK_ENABLE		   __HAL_RCC_GPIOB_CLK_ENABLE



#define POSITION_1_PORT			 	GPIOB	
#define POSITION_2_PORT			 	GPIOB	
#define POSITION_3_PORT			 	GPIOB	
#define POSITION_4_PORT			 	GPIOB	
#define POSITION_5_PORT			 	GPIOC	
#define POSITION_6_PORT			 	GPIOC	
#define POSITION_7_PORT			 	GPIOC	
#define POSITION_8_PORT			 	GPIOC	
#define LED_1_PORT	  	 		 	GPIOC
#define LED_2_PORT	  	 		 	GPIOC

#define POSITION_1_PIN           	GPIO_PIN_8
#define POSITION_2_PIN           	GPIO_PIN_7
#define POSITION_3_PIN           	GPIO_PIN_6
#define POSITION_4_PIN           	GPIO_PIN_5
#define POSITION_5_PIN           	GPIO_PIN_1
#define POSITION_6_PIN           	GPIO_PIN_0
#define POSITION_7_PIN           	GPIO_PIN_3
#define POSITION_8_PIN           	GPIO_PIN_2
#define LED_RED       	  		 	GPIO_PIN_15
#define LED_BLUE		 		 	GPIO_PIN_13

#define POSITION_1_PORT_CLK_ENABLE	__HAL_RCC_GPIOB_CLK_ENABLE
#define POSITION_2_PORT_CLK_ENABLE	__HAL_RCC_GPIOB_CLK_ENABLE
#define POSITION_3_PORT_CLK_ENABLE	__HAL_RCC_GPIOB_CLK_ENABLE
#define POSITION_4_PORT_CLK_ENABLE	__HAL_RCC_GPIOB_CLK_ENABLE
#define POSITION_5_PORT_CLK_ENABLE	__HAL_RCC_GPIOC_CLK_ENABLE
#define POSITION_6_PORT_CLK_ENABLE	__HAL_RCC_GPIOC_CLK_ENABLE
#define POSITION_7_PORT_CLK_ENABLE	__HAL_RCC_GPIOC_CLK_ENABLE
#define POSITION_8_PORT_CLK_ENABLE	__HAL_RCC_GPIOC_CLK_ENABLE
#define LED_RED_PORT_CLK_ENABLE		__HAL_RCC_GPIOC_CLK_ENABLE
#define LED_BLUE_PORT_CLK_ENABLE	__HAL_RCC_GPIOC_CLK_ENABLE
typedef struct
{
	uint8_t left_1_sw;
	uint8_t left_2_sw;
	uint8_t right_1_sw;
	uint8_t right_2_sw;
	uint8_t middle_sw;
}OPTO_FDBK,*P_OPTO_FDBK;

typedef enum
{
    OP_TOUCH,
    OP_NOT_TOUCH
} OP_STATE;

typedef enum
{
    L_FORWARD,
    R_FORWARD,
    L_BACK,
    R_BACK,
	  SIDE,
	  L_BULLET,
	  R_BULLET,
	  SPARE,
} OP_NUM;

void Opto_switch_Init(void);
OP_STATE Opto_switch_Read_State(OP_NUM op_num);
#endif

